package main

import (
	"fmt"
	"strconv"
	"sync"
	"time"
)

var wg = sync.WaitGroup{}

func main() {

	var arr = []int{}
	fmt.Println(arr)
	var qie = [5]int{}
	fmt.Println(qie)
	var m = make(map[int]int, 3)
	fmt.Println(m)
	var c = make(chan int, 3)
	fmt.Println(c)
	return

	ch := make(chan int, 1)
	defer close(ch)
	for i := 0; i < 10; i++ {
		//go func() {
		//	fmt.Println(i)
		//}()
		ch <-i
		//wg.Add(1)
		go hello(ch)
	}
	//time.Sleep(time.Second * 30)
	wg.Wait()
}

func i(i interface{}) interface{} {
	fmt.Println(i)
	return i
}
func demo2() {
	ch := make(chan string)
	go func() {
		// 这里假设执行一些耗时的操作
		time.Sleep(3 * time.Second)
		ch <- "job result"
	}()

	select {
	case result := <-ch:
		fmt.Println(result)
	case <-time.After(time.Second): // 较小的超时时间
		//t := <-time.After(time.Second)
		//fmt.Println(t)
		return
	}
}

func hello(ch chan int) {
	i := <- ch
	fmt.Println("hello " + strconv.Itoa(i))
	defer wg.Done()
}

